<?php

abstract class MVC_AbstractDBModel implements MVC_IModel
{
    protected $db;

    public function __construct()
    {
        $this->_host        = Config::get('db.host');

        $this->_user        = Config::get('db.username');

        $this->_pass        = Config::get('db.password');

        $this->_database    = Config::get('db.database');

        $this->db           = new fDatabase('mysql', Config::get('db.database') , Config::get('db.username'), Config::get('db.password'), Config::get('db.host'));   

        $this->db->connect();
    }

    public function createOrUpdate($array, $table ,$pk = 'id')
    {

        $query  = sprintf("SELECT * FROM `%s` WHERE `id` = %d", $tableName, $id);

        $result = $this->query($query);

        if($result->num_rows == 0)
        {
            return false;
        }

        return $result->fetch_assoc();
    }

    public function delete($table, $id, $pk = 'id')
    {

    }

    public function getByPk($id, $tableName)
    {

    }

    public function query($query)
    {
        $result = $this->db->query($query);

        
    }
}
